﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="zj_add.aspx.cs" Inherits="admin_zj_add" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="images/style.css" type="text/css" rel="stylesheet" />
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="../ckfinder/ckfinder.js" type="text/javascript"></script>
    <script type="text/javascript">
        function BrowseServer(functionData) {
            // You can use the "CKFinder" class to render CKFinder in a page:
            var finder = new CKFinder();

            // The path for the installation of CKFinder (default = "/ckfinder/").
            finder.basePath = '../';

            //Startup path in a form: "Type:/path/to/directory/"
            finder.startupPath = 'Comics:/' + decodeURI($('#' + functionData).val());

            // Name of a function which is called when a file is selected in CKFinder.
            finder.selectActionFunction = SetFileField;

            // Additional data to be passed to the selectActionFunction in a second argument.
            // We'll use this feature to pass the Id of a field that will be updated.
            finder.selectActionData = functionData;

            // Name of a function which is called when a thumbnail is selected in CKFinder.
            finder.selectThumbnailActionFunction = ShowThumbnails;

            finder.selectMultiple = true;

            // Launch CKFinder
            finder.popup();
        }

        // This is a sample function which is called when a file is selected in CKFinder.
        function SetFileField(fileUrl, data) {
            var arr = fileUrl.split('/');
            var tpadd = "";
            for (var i = 3; i < arr.length - 1; i++) {
                tpadd += arr[i] + "/";
            }
            document.getElementById(data["selectActionData"]).value = decodeURI(tpadd);
            ReadPictures();
        }

        // This is a sample function which is called when a thumbnail is selected in CKFinder.
        function ShowThumbnails(fileUrl, data) {
            // this = CKFinderAPI
            var sFileName = this.getSelectedFile().name;
            document.getElementById('thumbnails').innerHTML +=
			'<div class="thumb">' +
				'<img src="' + fileUrl + '" />' +
				'<div class="caption">' +
					'<a href="' + data["fileUrl"] + '" target="_blank">' + sFileName + '</a> (' + data["fileSize"] + 'KB)' +
				'</div>' +
			'</div>';

            document.getElementById('preview').style.display = "";
            // It is not required to return any value.
            // When false is returned, CKFinder will not close automatically.
            return false;
        }
        function ReadPictures() {
            $.getJSON("server.aspx?a=readPictures&_t=" + new Date(), { tpadd: $("#tpadd").val() },
                    function (data) {
                        if (data.error) {
                            alert(data.error);
                        } else {
                            var tpurl = [];
                            for (var i = 0; i < data.length; i++) {
                                if (data[i].OriginalPath != "Thumbs.db") {
                                    tpurl.push(data[i].OriginalPath);
                                }
                            }
                            $("#tpurl").val(tpurl.join('|'))
                            $("#tps").val(tpurl.length)
                        }

                    });
        }
    </script>
</head>
<body>
    <form id="form1" name="form1" method="post" action="?comicid=<%=Request["comicid"]%>&cjcomicid=<%=Request["cjcomicid"]%>&act=save">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="3972B4">
            <td colspan="3" bgcolor="e7e7e7">
                <div align="center">
                    <strong><font color="#000000">
                        <%=ninfo%>章节数据</font></strong></div>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="17%">
                <div align="right">
                    章节名称</div>
            </td>
            <td width="83%">
                <input name="zjmc" type="text" id="zjmc" value="<%=zj.zjmc%>" size="40" /><input
                    name="id" type="hidden" id="id" value="<%=zj.id%>" size="40" /><input name="cid"
                        type="hidden" id="cid" value="<%=Request["comicid"]%>" size="40" />
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="17%">
                <div align="right">
                    章节图片地址</div>
            </td>
            <td width="83%">
                <input name="tpadd" type="text" id="tpadd" value="<%=zj.tpadd%>" size="40" />
                <input type="button" value="浏览" onclick="BrowseServer( 'tpadd' );" />
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="17%">
                <div align="right">
                    图片数目
                </div>
            </td>
            <td width="83%">
                <input name="tps" type="text" readonly="readonly" id="tps" value="<%=zj.tps%>" size="40" />
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="17%" bgcolor="#FFFFFF">
                <div align="right">
                    通配符</div>
            </td>
            <td colspan="2">
                <input name="tpf" type="text" id="tpf" value="<%=zj.tpf%>" size="40" />
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="17%" bgcolor="#FFFFFF">
                <div align="right">
                    章节图片</div>
            </td>
            <td colspan="2">
                <textarea id="tpurl" name="tpurl" rows="10" cols="10" style="width: 273px;"><%=zj.tpurl%></textarea>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td colspan="3">
                <div align="center">
                    <input type="submit" name="Submit" class="Submit" value="确认<%=ninfo%>" />
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
